<template>
  <div class="login">
    <h1>熙康体检系统</h1>
    <el-form :model="loginForm" label-width="100px">
      <el-form-item label="用户名">
        <el-input v-model="loginForm.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="loginForm.password" show-password></el-input>
      </el-form-item>
      <el-form-item label="验证码">
        <el-input v-model="loginForm.captcha" style="width: 60%"></el-input>
        <el-button type="primary" @click="refreshCaptcha" class="captcha-refresh">看不清楚，换一张</el-button>
      </el-form-item>
      <el-form-item>
        <el-checkbox v-model="loginForm.autoLogin">自动登录</el-checkbox>
        <el-button type="primary" @click="onSubmit">登录</el-button>
        <el-button @click="goToRegister">注册</el-button>
        <el-button @click="goToForgotPassword">忘记密码</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'LoginPage',
  data() {
    return {
      loginForm: {
        username: '',
        password: '',
        captcha: '',
        autoLogin: false
      }
    };
  },
  methods: {
    onSubmit() {
      console.log('submit!', this.loginForm);
      // 这里可以添加登录逻辑
      this.$router.push('/home');
    },
    goToRegister() {
      this.$router.push('/register'); // 假设注册页面的路由是 /register
    },
    goToForgotPassword() {
      this.$router.push('/forgot-password');
    },
    refreshCaptcha() {
      // 这里可以添加刷新验证码的逻辑
      console.log('刷新验证码');
    }
  }
};
</script>

<style scoped>
.login {
  max-width: 500px;
  margin: 50px auto;
  padding: 40px;
  background: linear-gradient(135deg, #f2f2f2, #e6e6e6);
  border-radius: 15px;
  box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.login:hover {
  transform: translateY(-5px);
}

.el-form-item__label {
  font-weight: bold;
  color: #333;
}

.el-button {
  margin-top: 20px;
}

.captcha-refresh {
  margin-left: 10px;
}
</style>
